package com.jushu.storbox.actions;

import android.content.Context;
import android.os.Handler;
import android.os.Message;

import com.jushu.storbox.ShareDriveApplication;
import com.jushu.storbox.constant.MessageCode;
import com.jushu.storbox.util.LogUtil;
import com.huawei.sharedrive.sdk.android.exception.ClientException;
import com.huawei.sharedrive.sdk.android.modelV2.request.MailMsg;
import com.huawei.sharedrive.sdk.android.serviceV3.MailMsgClientV3;

public class MailMsgAction extends BaseAction {

	private static final String TAG = MailMsgAction.class.getSimpleName();

	public void getMailMsg(Context context, Handler msgHandler,
			final String type,final String ownerId, final String nodeId) {
		LogUtil.i(TAG, "batchShare[Actions]");
		executeRunTask(new RealTaskRunnable(context, msgHandler) {
			@Override
			protected void doTask(Context context, Handler msgHandler)
					throws ClientException {
				MailMsg mailMsg = MailMsgClientV3.getInstance().getMailMsg(
						ShareDriveApplication.getInstance().getAuthorization(),
						type, ownerId, nodeId);
				Message msg = msgHandler.obtainMessage();
				msg.what = MessageCode.MAIL_MSG_LOAD;
				msg.obj = mailMsg;
				msg.sendToTarget();
			}
		});
	}
}
